﻿
using IcicleFramework.Components.Actions;
using IcicleFramework.Components.Physics;
using Microsoft.Xna.Framework;

namespace ExampleGame.Components.Actions
{
    class PaddleImpulseAction : ImmediateAction
    {
        public override IAction DeepClone()
        {
            return new PaddleImpulseAction();
        }

        protected override void Execute(GameTime gameTime)
        {
            //Find the physics component for the target.
            IPhysicsComponent physics = Target.GetComponent<IPhysicsComponent>();

            //Retrieve our action data that we want.
            float impulse = (float) ActionData["impulse"];

            if (physics != null)
            {
                physics.ApplyImpulse(new Vector2(impulse, 0f));
            }

            base.Execute(gameTime);
        }
    }
}
